import { reqGetGoodDetailInfoData } from "@/api"

const state = {
  goodInfo:{}
}
const actions = {
  async getGoodDetailInfoData({commit},id) {
    const result = await reqGetGoodDetailInfoData(id)
    if (result.code === 200) {
      commit('SAVE_GOOD_DETAIL_INFO',result.data)
    }
  }
}
const mutations = {
  SAVE_GOOD_DETAIL_INFO(state,payload) {
    state.goodInfo = payload
  }
}
const getters = {
  categoryView(state) {
    return state.goodInfo.categoryView || {}
  },
  skuInfo(state) {
    return state.goodInfo.skuInfo || {}
  },
  spuSaleAttrList(state) {
    return state.goodInfo.spuSaleAttrList || []
  }
}
export default {
  namespaced:true,
  state,
  actions,
  mutations,
  getters
}